var xmlHttp

function addusr(url, type) 
{
var param = 'user='+document.forms[0].user.value;
param = param+'&password='+document.forms[0].password.value;
param = param+'&confirm_password='+document.forms[0].confirm_password.value;
param = param+'&home_dir='+document.forms[0].home_dir.value;
param = param+'&trash_dir='+document.forms[0].trash_dir.value;
param = param+'&trash_file='+document.forms[0].trash_file.value;
param = param+'&userpath='+document.forms[0].userpath.value;
      for (var i=0; i < document.forms[0].power.length; i++)
         {
         if (document.forms[0].power[i].checked)
            {
            var power = document.forms[0].power[i].value;
            }
         }
      param = param+'&power='+power;
submitForm(url, type, param);
}

function checkAll()
{
	for(var i=0; document.forms[0].file[i]; i++) {
		if(document.forms[0].all.checked == true) {
			document.forms[0].file[i].checked = true;
		} else {
			document.forms[0].file[i].checked = false;
		}
	}
}

function update(url, type) 
{
	var param = 'update=true';
	for(var i=0; document.forms[0].file[i]; i++) {
		if(document.forms[0].all.checked == true) { var check = confirm("Warning: not updating oPanel will void your support warrenty\nAre you sure you do not wish to update any files?");
		if (check){ showContent('main'); } else { return false; } }
		if(document.forms[0].file[i].checked == true) {
			var check = true; } 
		if(document.forms[0].file[i].checked == false) {
		param = param+'&file['+i+']='+document.forms[0].file[i].value; }
	}
if(check != true) { submitForm(url, type, param); } else { var check = confirm("Warning: not updating oPanel will void your support warrenty and could lead to potential exploits\nAre you sure you do not wish to perform all avaliable file updates?"); if(check) { submitForm(url, type, param); } else { return false; }  }
return true;
}

function repBug(url, type) {
var param = 'name='+document.forms[0].name.value;
param = param+'&subject='+document.forms[0].subject.value;
param = param+'&details='+document.forms[0].details.value;
submitForm(url, type, param); }

function changeSet(url, type) {
      for (var i=0; i < document.forms[0].del.length; i++)
         {
         if (document.forms[0].del[i].checked)
            {
            var del = document.forms[0].del[i].value;
            }
         }
     var param = 'del='+del;
      for (var i=0; i < document.forms[0].edit.length; i++)
         {
         if (document.forms[0].edit[i].checked)
            {
            var edit = document.forms[0].edit[i].value;
            }
         }
         param = param+'&edit='+edit;
      for (var i=0; i < document.forms[0].rename.length; i++)
         {
         if (document.forms[0].rename[i].checked)
            {
            var rename = document.forms[0].rename[i].value;
            }
         }
         param = param+'&rename='+rename;
      for (var i=0; i < document.forms[0].copy.length; i++)
         {
         if (document.forms[0].copy[i].checked)
            {
            var copy = document.forms[0].copy[i].value;
            }
         }
         param = param+'&copy='+copy;
      for (var i=0; i < document.forms[0].move.length; i++)
         {
         if (document.forms[0].move[i].checked)
            {
            var move = document.forms[0].move[i].value;
            }
         }
         param = param+'&move='+move;
      for (var i=0; i < document.forms[0].upload.length; i++)
         {
         if (document.forms[0].upload[i].checked)
            {
            var upload = document.forms[0].upload[i].value;
            }
         }
         param = param+'&upload='+upload;
param = param+'&password='+document.forms[0].password.value;
submitForm(url, type, param); }

function ABSconf(url, type) {
      for (var i=0; i < document.forms[0].ABS.length; i++)
         {
         if (document.forms[0].ABS[i].checked)
            {
            var ABS = document.forms[0].ABS[i].value;
            }
         }
     var param = 'ABS='+ABS;
      for (var i=0; i < document.forms[0].InstBan.length; i++)
         {
         if (document.forms[0].InstBan[i].checked)
            {
            var InstBan = document.forms[0].InstBan[i].value;
            }
         }
         param = param+'&InstBan='+InstBan;
      for (var i=0; i < document.forms[0].authLogged.length; i++)
         {
         if (document.forms[0].authLogged[i].checked)
            {
            var authLogged = document.forms[0].authLogged[i].value;
            }
         }
         param = param+'&authLogged='+authLogged;
      for (var i=0; i < document.forms[0].accessAdmin.length; i++)
         {
         if (document.forms[0].accessAdmin[i].checked)
            {
            var accessAdmin = document.forms[0].accessAdmin[i].value;
            }
         }
         param = param+'&accessAdmin='+accessAdmin;
      for (var i=0; i < document.forms[0].SMART.length; i++)
         {
         if (document.forms[0].SMART[i].checked)
            {
            var SMART = document.forms[0].SMART[i].value;
            }
         }
         param = param+'&SMART='+SMART;
      for (var i=0; i < document.forms[0].upload.length; i++)
         {
         if (document.forms[0].upload[i].checked)
            {
            var upload = document.forms[0].upload[i].value;
            }
         }
         param = param+'&upload='+upload;
param = param+'&cautLimit='+document.forms[0].cautLimit.value;
param = param+'&banLength='+document.forms[0].banLength.value;
submitForm(url, type, param); }

function SetCheckPass(url, type) {
var param = 'del='+document.forms[0].del.value;
param = param+'&rename='+document.forms[0].rename.value;
param = param+'&copy='+document.forms[0].copy.value;
param = param+'&move='+document.forms[0].move.value;
param = param+'&upload='+document.forms[0].upload.value;
param = param+'&password='+document.forms[0].password.value;
submitForm(url, type, param); }

function udtf(intal,val) {
	if(val == '') {
	document.forms[0].trash_file.value='Please enter a user name';
	document.forms[0].trash_dir.value='Please enter a user name';
	document.forms[0].home_dir.value='Please enter a user name';
	document.forms[0].trash_file.disabled=true;
	document.forms[0].trash_dir.disabled=true;
	document.forms[0].home_dir.disabled=true;
	document.forms[0].addUsr.disabled=true;
	} 
	else
	{
	document.forms[0].trash_file.disabled=false;
	document.forms[0].trash_dir.disabled=false;
	document.forms[0].home_dir.disabled=false;
	document.forms[0].addUsr.disabled=false;
	document.forms[0].trash_file.value=intal+val+'.optf';
	document.forms[0].trash_dir.value=intal+'trash/'+val+'/';
	document.forms[0].home_dir.value=intal+val+'/';
	}
}

function showContent(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  document.getElementById("content").innerHTML='<p>&nbsp;</p><p>&nbsp;</p>'
  +'<center><img src="./images/loading.gif" alt="Loading..." /></center>';
var url="admin/page.php";
url=url+"?page="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function submitForm(url, type, param)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  document.getElementById("content").innerHTML='<p>&nbsp;</p><p>&nbsp;</p>'
  +'<center><img src="./images/loading.gif" alt="Loading..." /></center>';
xmlHttp.onreadystatechange=stateChanged;
if(param != "") { url=url+"?"+param; }
type = type == "POST" ? "POST" : "GET";
xmlHttp.open(type,url,true);
if ( type == "GET" )
		{
			xmlHttp.send(null);
		}
		else
		{
			if ( typeof( xmlHttp.setRequestHeader ) != "undefined" )
			{
				xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			}
			xmlHttp.send( param );
		}
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("content").innerHTML=xmlHttp.responseText;
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}